#include <stdio.h>
#include <stdlib.h>  // 用于system函数
#include <conio.h>
#include <iostream>
#include <windows.h>
#include <string>
#define COLOR_HIGHLIGHT "\033[1;31m"
#define COLOR_CLEAR "\033[0m"
#define DATE_WIDTH 12
#define FESTIVAL_WIDTH 20
struct pdate{//返回公历日期的结构体
    int year;
    int month;
    int day;
};
typedef struct//返回月历信息的结构体
{
    int month;
    int day;
}Date;
typedef struct data
{
	int solarday;
	char lunarday[20];
}daystruct;
Date solarterm[126][24]=//1900-2025各年份节气数据
{
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,7},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,7},{3,22},{4,6},{4,21},{5,7},{5,22},{6,7},{6,22},{7,8},{7,24},{8,9},{8,24},{9,9},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,7},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,7},{3,22},{4,6},{4,21},{5,7},{5,22},{6,7},{6,22},{7,8},{7,24},{8,9},{8,24},{9,9},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,7},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,7},{3,22},{4,6},{4,21},{5,7},{5,22},{6,7},{6,22},{7,8},{7,24},{8,9},{8,24},{9,9},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,7},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,22},{4,5},{4,21},{5,6},{5,22},{6,7},{6,22},{7,8},{7,24},{8,8},{8,24},{9,9},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,21},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,22},{4,6},{4,21},{5,6},{5,22},{6,7},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,8},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,7},{6,22},{7,8},{7,24},{8,8},{8,24},{9,9},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,7},{6,22},{7,8},{7,24},{8,8},{8,24},{9,9},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,7},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,8},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,6},{3,21},{4,6},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,24}},
    {{1,6},{1,21},{2,5},{2,20},{3,6},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,5},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,24},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,23}},
    {{1,6},{1,21},{2,5},{2,20},{3,5},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,20},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,5},{3,20},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,24},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,22},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,21},{4,5},{4,21},{5,6},{5,21},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,5},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,8},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,8},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,5},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,24},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,4},{2,19},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,4},{2,18},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,4},{2,18},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,4},{2,18},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,4},{2,18},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,9},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,6},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,22},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,4},{2,18},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,23},{12,7},{12,22}},
    {{1,6},{1,21},{2,4},{2,19},{3,5},{3,20},{4,4},{4,20},{5,5},{5,20},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,22},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,4},{2,18},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,22},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,5},{3,20},{4,4},{4,19},{5,5},{5,20},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,22},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,3},{2,18},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,5},{3,21},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,8},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,5},{3,20},{4,4},{4,19},{5,5},{5,20},{6,5},{6,21},{7,6},{7,22},{8,7},{8,22},{9,7},{9,22},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,3},{2,18},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}},
    {{1,5},{1,20},{2,4},{2,19},{3,5},{3,20},{4,5},{4,20},{5,5},{5,21},{6,6},{6,21},{7,7},{7,23},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,22}},
    {{1,5},{1,20},{2,4},{2,19},{3,6},{3,21},{4,5},{4,20},{5,6},{5,21},{6,6},{6,21},{7,7},{7,23},{8,8},{8,23},{9,8},{9,23},{10,8},{10,24},{11,8},{11,22},{12,7},{12,22}},
    {{1,6},{1,20},{2,4},{2,19},{3,5},{3,20},{4,4},{4,19},{5,5},{5,20},{6,5},{6,21},{7,6},{7,22},{8,7},{8,22},{9,7},{9,22},{10,8},{10,23},{11,7},{11,22},{12,8},{12,21}},
    {{1,5},{1,20},{2,3},{2,18},{3,5},{3,20},{4,4},{4,20},{5,5},{5,21},{6,5},{6,21},{7,7},{7,22},{8,7},{8,23},{9,7},{9,23},{10,8},{10,23},{11,7},{11,22},{12,7},{12,21}}
};
const unsigned int lunarInfo[] = {//1900-2025农历闰月情况以及各月天数
    0x04BD8, 0x04AE0, 0x0A570, 0x04AE5, 0x0D260, 0x0D950, 0x16554, 0x056A0, 0x09AD0, 0x055D2,
    0x04AE0, 0x0A5B6, 0x0A4D0, 0x0D250, 0x1D255, 0x0B540, 0x0D6A0, 0x0ADA2, 0x095B0, 0x14977,
    0x04970, 0x0A4B0, 0x0B4B5, 0x06A50, 0x06D40, 0x1AB54, 0x02B60, 0x09570, 0x052F2, 0x04970,
    0x06566, 0x0D4A0, 0x0EA50, 0x16A95, 0x05AD0, 0x02B60, 0x186E3, 0x092E0, 0x1C8D7, 0x0C950,
    0x0D4A0, 0x1D8A6, 0x0B550, 0x056A0, 0x1A5B4, 0x025D0, 0x092D0, 0x0D2B2, 0x0A950, 0x0B557,
    0x06CA0, 0x0B550, 0x15355, 0x04DA0, 0x0A5B0, 0x14573, 0x052B0, 0x0A9A8, 0x0E950, 0x06AA0,
    0x0AEA6, 0x0AB50, 0x04B60, 0x0AAE4, 0x0A570, 0x05260, 0x0F263, 0x0D950, 0x05B57, 0x056A0,
    0x096D0, 0x04DD5, 0x04AD0, 0x0A4D0, 0x0D4D4, 0x0D250, 0x0D558, 0x0B540, 0x0B6A0, 0x195A6,
    0x095B0, 0x049B0, 0x0A974, 0x0A4B0, 0x0B27A, 0x06A50, 0x06D40, 0x0AF46, 0x0AB60, 0x09570,
    0x04AF5, 0x04970, 0x064B0, 0x074A3, 0x0EA50, 0x06B58, 0x05AC0, 0x0AB60, 0x096D5, 0x092E0,
    0x0C960, 0x0D954, 0x0D4A0, 0x0D550, 0x07552, 0x056A0, 0x0ABB7, 0x025D0, 0x092D0, 0x0CAB5,
    0x0A950, 0x0B4A0, 0x0BAA4, 0x0AD50, 0x055D9, 0x04BA0, 0x0A5B0, 0x15176, 0x052B0, 0x0A930,
    0x07954, 0x06AA0, 0x0AD50, 0x05B52, 0x04B60, 0x0A6E6
};

int getSolarMonthDays(int year, int month) {// 获取公历月份的天数

    static int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if (month == 2 && (year % 4 == 0 && year % 100 != 0 || year % 400 == 0))
        return 29;
    return days[month - 1];
}
int getDaysSince1900(int year, int month, int day) {//天数和
    int days = 0;
    for (int i = 1900; i < year; i++)
        days += 365 + (i % 4 == 0 && i % 100 != 0 || i % 400 == 0);
    for (int i = 1; i < month; i++)
        days += getSolarMonthDays(year, i);
    return days + day - 31;
}
// 公历转农历
int solarToLunar(int solarYear, int solarMonth, int solarDay,
                  int *lunarYear, int *lunarMonth, int *lunarDay,
                  int *isLeapMonth) {
    // 1. 验证输入日期有效性
    if (solarYear < 1900 || solarYear > 2100) return 0;
    if (solarMonth < 1 || solarMonth > 12) return 0;
    if (solarDay < 1 || solarDay > getSolarMonthDays(solarYear, solarMonth)) return 0;

    // 2. 计算自1900年1月31日起的天数
    int days = getDaysSince1900(solarYear, solarMonth, solarDay);
    if (days < 0) return 0; // 日期早于基准日

    // 3. 确定农历年份
    *lunarYear = 1900;
    while (1) {
        int leapMonth = (lunarInfo[*lunarYear - 1900] & 0xf); // 获取闰月
        int yearDays = 0; // 该年总天数

        // 计算该年农历总天数（包括可能的闰月）
        for (int i = 1; i <= 12; i++) {
            // 计算正常月份的天数
            yearDays += (lunarInfo[*lunarYear - 1900] >> (16 - i) & 0x1) ? 30 : 29;

            // 如果当前月是闰月，计算闰月的天数
            if (i == leapMonth && leapMonth > 0) {
                yearDays += (lunarInfo[*lunarYear - 1900] >> 16 & 0x1) ? 30 : 29;
            }
        }

        if (days < yearDays) break; // 找到对应的农历年
        days -= yearDays;
        (*lunarYear)++;
    }

    // 4. 确定农历月份和日期
    int i = 1;
    int leapMonth = (lunarInfo[*lunarYear - 1900] & 0xf); // 该年闰月
    *isLeapMonth = 0;

    while (i <= 12 && days >= 0) {
        int daysInMonth = (lunarInfo[*lunarYear - 1900] >> (16 - i) & 0x1) ? 30 : 29;
        *lunarMonth = i;
        *isLeapMonth = 0;

        // 处理正常月份
        if (days <= daysInMonth-1) { // 1900-1-31是农历1900-1-1日，所以-1
            *lunarDay = days+1;
            return 1;
        }
        days -= daysInMonth;

        // 如果当前月是闰月，处理闰月
        if (i == leapMonth && leapMonth > 0) {
            *isLeapMonth = 1;
            daysInMonth = (lunarInfo[*lunarYear - 1900] >> 16 & 0x1) ? 30 : 29;
            if (days <= daysInMonth-1) {
                *lunarDay = days+1;
                return 1;
            }
            days -= daysInMonth;
        }

        i++;
    }

    return 0; // 转换失败
}
// 输出公历转农历的结果
void solarToLunarOutput(int solarYear, int solarMonth, int solarDay) {
    int lunarYear, lunarMonth, lunarDay, isLeap;

    if (solarToLunar(solarYear, solarMonth, solarDay, &lunarYear, &lunarMonth, &lunarDay, &isLeap)) {
        printf("公历%d年%d月%d日对应的农历是：%d年", solarYear, solarMonth, solarDay, lunarYear);
        if (isLeap)
            printf("闰");
        printf("%d月%d日\n", lunarMonth, lunarDay);
    } else {
        printf("转换失败\n");
    }
}
int emonth[12]={31,28,31,30,31,30,31,31,30,31,30,31};//储存公历月份的数组
std::string week[]={"星期六","星期日","星期一","星期二","星期三","星期四","星期五"};//输出对应星期的字符数组
pdate date(int dif){//根据天数差返回具体日期的函数
    pdate result;
     result.year=(dif/365);
     result.day=(dif%365);
     result.month=1;
    for(int i=1900;i<result.year+1900;i++){
        if((i%4==0&&i%100!=0)||i%400==0){
            result.day--;
        }
    }
    if((result.year%4==0&&result.year%100!=0)||result.year%400==0){
            emonth[1]=29;
        }
    for(int i=0;i<12;i++){
        if(result.day>emonth[i]){
            result.month++;
            result.day-=emonth[i];
            //cout<<result.day<<endl;
        }
        else break;
    }
    return result;
}
bool isright(int year,int month,int day){//判断输入的公历日期是否合法的函数
    if(year>=1840&&year<=2100) {
        if(month>=1&&month<=12){
            if(day>=0&&day<=emonth[month-1])
                return 1;
            else return 0;
        }
        else return 0;
    }
    else return 0;
}
int daysum(int year,int month,int day){//计算公历天数和的函数
    int sum=0;
    for(int i=1900;i<year;i++){
        if((i%4==0&&i%100!=0)||i%400==0){
            sum+=366;
        }
        else sum+=365;
    }
    if((year%4==0&&year%100!=0)||year%400==0){
            emonth[1]=29;}
    else emonth[1]=28;
    for(int i=0;i<month-1;i++){
        sum+=emonth[i];
    }
    sum+=day;
    return sum;
}
int get_weekday(int year,int month,int day)//星期查询函数
{
    if(month<3)
    {
        month+=12;
        year--;

    }
    int j=year/100;
    int k=year%100;
    int h=(day+13*(month+1)/5+k+k/4+j/4-2*j)%7;//利用蔡氏公式计算
    int x=(h+7)%7;//返回值代表：0=Sat. 1=Sun. 2=Mon. 3=Tues. 4=Wed. 5=Thur. 6=Fri.
    return x;
}
int lunarToDays(int lunarYear, int lunarMonth, int lunarDay, int isLeapMonth) {//农历转公历计算函数
    int totalDays = 0;

    // 1. 输入有效性校验
    if (lunarYear < 1900 || lunarYear > 2100) {
        printf("年份超出范围(1900-2100)\n");
        return -1;
    }
    if (lunarMonth < 1 || lunarMonth > 12) {
        printf("月份错误(1-12)\n");
        return -1;
    }

    // 2. 验证闰月合法性
    int leapMonth = lunarInfo[lunarYear - 1900] & 0xF;
    if (isLeapMonth) {
        if (leapMonth == 0 || leapMonth != lunarMonth) {
            printf("该年无此闰月\n");
            return -1;
        }
    }

    // 3. 计算1900年至目标年份前一年的总天数
    for (int y = 1900; y < lunarYear; y++) {
        int yearData = lunarInfo[y - 1900];
        int leap = yearData & 0xF; // 获取闰月
        int days = 0;

        // 计算全年总天数
        for (int m = 1; m <= 12; m++) {
            days += (yearData >> (16 - m) & 0x1) ? 30 : 29;
            if (m == leap && leap > 0) {
                days += (yearData >> 16 & 0x1) ? 30 : 29;
            }
        }
        totalDays += days;
    }

    // 4. 计算目标年份的月份天数
    int yearData = lunarInfo[lunarYear - 1900];
    int currentLeap = yearData & 0xF;
    int monthPassed = 0;

    for (int m = 1; m <= 12; m++) {
        // 处理正常月份
        int isBig = (yearData >> (16 - m)) & 0x1;
        int normalDays = isBig ? 30 : 29;

        // 如果当前是目标月份
        if (!isLeapMonth && m == lunarMonth) {
            if (lunarDay < 1 || lunarDay > normalDays) {
                printf("日期超出范围\n");
                return -1;
            }
            totalDays += lunarDay; // 天数从0开始累计
            return totalDays;
        }
        totalDays += normalDays;
        // 处理闰月
        if (m == currentLeap) {
            int leapDays = (yearData >> 16 & 0x1) ? 30 : 29;
            if (isLeapMonth && m == lunarMonth) {
                if (lunarDay < 1 || lunarDay > leapDays) {
                    printf("日期超出范围\n");
                    return -1;
                }
                totalDays += lunarDay;
                return totalDays;
            }
            totalDays += leapDays;
        }
    }

    return -1;
}
int calculateDays() {//返回农历转公历结果的函数
    int year, month, day, isLeap;
    printf("请输入农历日期（年 月 日 是否闰月[0/1]）：");
    scanf("%d %d %d %d", &year, &month, &day, &isLeap);

    int days = lunarToDays(year, month, day, isLeap);
    return days;
}
daystruct solarToLunarDay(int solarYear, int solarMonth, int solarDay) {
    int lunarYear, lunarMonth, lunarDay, isLeap;
    daystruct temp={0};
	const char* lunar_month_names[] = {"正月", "二月", "三月", "四月", "五月", "六月",
                                      "七月", "八月", "九月", "十月", "冬月", "腊月"};
	const char* lunar_day_names[] = {"初一", "初二", "初三", "初四", "初五", "初六", "初七", "初八", "初九", "初十",
                                    "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十",
                                    "廿一", "廿二", "廿三", "廿四", "廿五", "廿六", "廿七", "廿八", "廿九", "三十"};


    if (solarToLunar(solarYear, solarMonth, solarDay, &lunarYear, &lunarMonth, &lunarDay, &isLeap))
	{

        if (isLeap)
            {
            	sprintf(temp.lunarday,"闰%s%s",lunar_month_names[lunarMonth-1],lunar_day_names[lunarDay-1]);
			}
		else
			{
				sprintf(temp.lunarday,"%s%s",lunar_month_names[lunarMonth-1],lunar_day_names[lunarDay-1]);
			}
		temp.solarday=solarDay;
    }
    return temp;
}
char *JudgeSolarTerm(int year,int month,int day,char *term)//返回节气的函数
{
	int yearRank=year-1900;
	int solartermRank=-1;
	if(solarterm[yearRank][2*month-2].day==day)
	{
		solartermRank=2*month-2;
	}
	else if(solarterm[yearRank][2*month-1].day==day)
	{
		solartermRank=2*month-1;
	}
	strcpy(term,"");
	if(solartermRank>-1)
	{
		switch(solartermRank)
		{
			case 0:strcpy(term,"小寒");break;
			case 1:strcpy(term,"大寒");break;
			case 2:strcpy(term,"立春");break;
			case 3:strcpy(term,"雨水");break;
			case 4:strcpy(term,"惊蛰");break;
			case 5:strcpy(term,"春分");break;
			case 6:strcpy(term,"清明");break;
			case 7:strcpy(term,"谷雨");break;
			case 8:strcpy(term,"立夏");break;
			case 9:strcpy(term,"小满");break;
			case 10:strcpy(term,"芒种");break;
			case 11:strcpy(term,"夏至");break;
			case 12:strcpy(term,"小暑");break;
			case 13:strcpy(term,"大暑");break;
			case 14:strcpy(term,"立秋");break;
			case 15:strcpy(term,"处暑");break;
			case 16:strcpy(term,"白露");break;
			case 17:strcpy(term,"秋分");break;
			case 18:strcpy(term,"寒露");break;
			case 19:strcpy(term,"霜降");break;
			case 20:strcpy(term,"立冬");break;
			case 21:strcpy(term,"小雪");break;
			case 22:strcpy(term,"大雪");break;
			case 23:strcpy(term,"冬至");break;
		}
	}
	return term;
}
void calenderOutPut(int year,int month,int day)//月历显示函数
{
	if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
        emonth[1] = 29;
    }
    int weekday = get_weekday(year, month, 1);
    printf("\t\t\t\t\t\t%d月 %d年\n", month, year);
    printf("一\t\t二\t\t三\t\t四\t\t五\t\t六\t\t日\n");
    if (weekday <= 1) weekday += 6;
    else weekday -= 1;
    int row = 0, col = weekday - 1;
    daystruct calendar[6][7]={0};
	// 初始化数组
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {
            strcpy(calendar[i][j].lunarday, "");
            calendar[i][j].solarday=0;
        }
    }
    // 填充农历日期结构体到calendar数组
    for (int i = 1; i <= emonth[month - 1]; i++) {
        calendar[row][col]=solarToLunarDay(year,month,i);
        char term[10];
        if(JudgeSolarTerm(year,month,i,term)[0]!='\0')
        {
            strcpy(calendar[row][col].lunarday,JudgeSolarTerm(year,month,i,term));
        }
        col++;
        if (col >= 7) {
            col = 0;
            row++;
        }
    }
     // 打印公历和农历日期
    for (int i = 0; i < 6; i++) {
        // 打印公历日期行
        for (int j = 0; j < 7; j++) {
            if (calendar[i][j].lunarday[0]== '\0')//多余的calendar数组
                printf("\t\t");  // 两个制表符保持列对齐
            else
            {
                if(j==5||j==6)
                {
                    printf("%-2d\t\t", calendar[i][j].solarday);  // 公历日期后两个制表符
                }
                else if(j<5)
                {
                    printf("%-2d\t\t", calendar[i][j].solarday);  // 公历日期后两个制表符
                }
            }
        }
        printf("\n");

        // 打印对应的农历日期行
        for (int j = 0; j < 7; j++) {
            if (calendar[i][j].lunarday[0] == '\0')
                printf("\t\t");  // 空单元格保持对齐
            else {
                    if(strlen(calendar[i][j].lunarday)<=6)
                printf("%-6s\t\t", calendar[i][j].lunarday);
                //是节气时，后面两个制表符
                    if(strlen(calendar[i][j].lunarday)>6)
                printf("%-6s\t", calendar[i][j].lunarday);
                // 非节气时农历日期后一个制表符
            }
        }
        printf("\n\n");  // 每组日期对之间空一行
    }
 }
void termdistance(int year,int month,int day)//节气距离函数（显示农历）
 {
    char term[7]="";
    int yearRank=year-1900;
	int solartermRank=-1;
	if(solarterm[yearRank][2*month-2].day==day)
	{
		solartermRank=2*month-2;
	}
	else if(solarterm[yearRank][2*month-1].day==day)
	{
		solartermRank=2*month-1;
	}
	if(solartermRank>-1)
	{
		switch(solartermRank)
		{
			case 0:strcpy(term,"小寒");break;
			case 1:strcpy(term,"大寒");break;
			case 2:strcpy(term,"立春");break;
			case 3:strcpy(term,"雨水");break;
			case 4:strcpy(term,"惊蛰");break;
			case 5:strcpy(term,"春分");break;
			case 6:strcpy(term,"清明");break;
			case 7:strcpy(term,"谷雨");break;
			case 8:strcpy(term,"立夏");break;
			case 9:strcpy(term,"小满");break;
			case 10:strcpy(term,"芒种");break;
			case 11:strcpy(term,"夏至");break;
			case 12:strcpy(term,"小暑");break;
			case 13:strcpy(term,"大暑");break;
			case 14:strcpy(term,"立秋");break;
			case 15:strcpy(term,"处暑");break;
			case 16:strcpy(term,"白露");break;
			case 17:strcpy(term,"秋分");break;
			case 18:strcpy(term,"寒露");break;
			case 19:strcpy(term,"霜降");break;
			case 20:strcpy(term,"立冬");break;
			case 21:strcpy(term,"小雪");break;
			case 22:strcpy(term,"大雪");break;
			case 23:strcpy(term,"冬至");break;
		}
	}

	if(solartermRank>-1)
    {
        printf("\n%d年%d月%d日是%s\n",year,month,day,term);
    }
    else
    {
        int gap1=0,gap2=0;
        gap1=day-solarterm[yearRank][2*month-2].day;
        gap2=day-solarterm[yearRank][2*month-1].day;
        if(gap1<0)
            gap1=-gap1;
        if(gap2<0)
            gap2=-gap2;
        if(gap1<gap2)
        {
            switch(2*month-2)
            {
                case 0:printf("距离最近的节气是小寒，还有%d天\n",gap1);break;
                case 2:printf("距离最近的节气是立春，还有%d天\n",gap1);break;
                case 4:printf("距离最近的节气是惊蛰，还有%d天\n",gap1);break;
                case 6:printf("距离最近的节气是清明，还有%d天\n",gap1);break;
                case 8:printf("距离最近的节气是立夏，还有%d天\n",gap1);break;
                case 10:printf("距离最近的节气是芒种，还有%d天\n",gap1);break;
                case 12:printf("距离最近的节气是小暑，还有%d天\n",gap1);break;
                case 14:printf("距离最近的节气是立秋，还有%d天\n",gap1);break;
                case 16:printf("距离最近的节气是白露，还有%d天\n",gap1);break;
                case 18:printf("距离最近的节气是寒露，还有%d天\n",gap1);break;
                case 20:printf("距离最近的节气是立冬，还有%d天\n",gap1);break;
                case 22:printf("距离最近的节气是大雪，还有%d天\n",gap1);break;
            }
        }
        if(gap2<gap1)
        {
            switch(2*month-1)
            {
                case 1:printf("距离最近的节气是大寒，还有%d天\n",gap2);break;
                case 3:printf("距离最近的节气是雨水，还有%d天\n",gap2);break;
                case 5:printf("距离最近的节气是春分，还有%d天\n",gap2);break;
                case 7:printf("距离最近的节气是谷雨，还有%d天\n",gap2);break;
                case 9:printf("距离最近的节气是小满，还有%d天\n",gap2);break;
                case 11:printf("距离最近的节气是夏至，还有%d天\n",gap2);break;
                case 13:printf("距离最近的节气是大暑，还有%d天\n",gap2);break;
                case 15:printf("距离最近的节气是处暑，还有%d天\n",gap2);break;
                case 17:printf("距离最近的节气是秋分，还有%d天\n",gap2);break;
                case 19:printf("距离最近的节气是霜降，还有%d天\n",gap2);break;
                case 21:printf("距离最近的节气是小雪，还有%d天\n",gap2);break;
                case 23:printf("距离最近的节气是冬至，还有%d天\n",gap2);break;
            }
        }
    }
 }
 void calculateGanZhiYear(int year, char *ganZhi) {//干支函数（显示农历）
    // 天干和地支的数组
    const char* tiangan[] = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
    const char* dizhi[] = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};

    // 计算天干和地支的索引
    int tianGanIndex = (year - 4) % 10;
    int diZhiIndex = (year - 4) % 12;

    // 处理可能的负数索引
    if (tianGanIndex < 0) tianGanIndex += 10;
    if (diZhiIndex < 0) diZhiIndex += 12;

    // 组合天干地支
    sprintf(ganZhi, "%s%s", tiangan[tianGanIndex], dizhi[diZhiIndex]);
}
void termOutPut(int year)
{
    int yearRank=year-1900;
    int i=0;
        printf("小寒在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("大寒在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("立春在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("雨水在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("惊蛰在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("春分在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("清明在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("谷雨在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("立夏在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("小满在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("芒种在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("夏至在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("小暑在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("大暑在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("立秋在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("处暑在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("白露在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("秋分在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("寒露在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("霜降在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("立冬在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("小雪在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("大雪在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
        i++;
        printf("冬至在%d月%d日\n",solarterm[yearRank][i].month,solarterm[yearRank][i].day);
}
// 页面1的功能函数
void page1() {
    system("cls");  // 进入页面时先清屏
    printf("欢迎来到页面1！\n");
    printf("查询农历\n");
    printf("请输入想要查询的公历日期\n");
    int iyear,imonth,iday;
    char ganZhi[10]={0};
    scanf("%d %d %d",&iyear,&imonth,&iday);
    termdistance(iyear,imonth,iday);
    calculateGanZhiYear(iyear,ganZhi);
    printf("%d年是%s年\n",iyear,ganZhi);
    calenderOutPut(iyear,imonth,iday);
    printf("按任意键返回主菜单...");

    getch();
}

// 页面2的功能函数
void page2() {
    system("cls");  // 进入页面时先清屏
    printf("欢迎来到页面2！\n");
    printf("查询公历\n");
    int totaldays=calculateDays();
    pdate pdate=date(totaldays);
    if(totaldays>0){
    printf("公历日期为%d %d %d\n",pdate.year+1900,pdate.month+1,pdate.day);}
    printf("按任意键返回主菜单...");
    getch();
}
//页面3的功能函数
void page3() {
    system("cls");  // 进入页面时先清屏
    printf("欢迎来到页面3！\n");
    printf("显示月历\n");
    printf("请输入想要查询的年月份\n");
    int iyear,imonth;
    scanf("%d %d",&iyear,&imonth);
    calenderOutPut(iyear,imonth,1);
    printf("\n按任意键返回主菜单...");
    getch();
}
//页面4的功能函数
void page4(int csum,int cyear,int cmonth,int cday) {
    system("cls");  // 进入页面时先清屏
    printf("欢迎来到页面4！\n");
    int iyear,imonth,iday;
    printf("查询某天距今天的天数\n");
    printf("请输入想要查询的天数\n");
    scanf("%d %d %d",&iyear,&imonth,&iday);
    int isum=daysum(iyear,imonth,iday);
    int dif=isum-csum;
    if(dif<0) {
            dif=-dif;
            printf("%d %d %d比今天(%d-%d-%d)早[%d]天\n",iyear,imonth,iday,cyear,cmonth,cday,dif);}
    else if(dif>0)  printf("%d %d %d比今天(%d-%d-%d)晚[%d]天\n",iyear,imonth,iday,cyear,cmonth,cday,dif);
    else printf("您输入的为同一天\n");
    printf("按任意键返回主菜单...");
    getch();
}
//页面5的功能函数
void page5(int csum,int cyear,int cmonth,int cday) {
    system("cls");  // 进入页面时先清屏
    printf("欢迎来到页面5！\n");
    printf("查询距今天相应天数的日期\n");
    int dif;
    printf("请输入天数:\n");
    scanf("%d",&dif);
    int x=0;
    x=(dif+csum);
    pdate pdate=date(x);
    int weekday=get_weekday(pdate.year+1900,pdate.month,pdate.day);
    printf("比今天（%d-%d-%d）晚[%d]天的日期为：%d年%d月%d日 ",cyear,cmonth,cday,dif,pdate.year+1900,pdate.month,pdate.day);
    printf("%s\n",(week[weekday]).c_str());//加c_str() 不会乱码
    x=(csum-dif);
    pdate=date(x);
    weekday=get_weekday(pdate.year+1900,pdate.month,pdate.day);
    printf("比今天（%d-%d-%d）早[%d]天的日期为：%d年%d月%d日 ",cyear,cmonth,cday,dif,pdate.year+1900,pdate.month,pdate.day);
    printf("%s\n",(week[weekday]).c_str());
    printf("按任意键返回主菜单...");
    getch();
}
//页面6的功能函数
void page6() {
    system("cls");  // 进入页面时先清屏
    printf("欢迎来到页面6！\n");
    printf("查询任意两天之间的天数差\n");
    printf("请输入两个天数\n");
    int year1,month1,day1,year2,month2,day2;
    scanf("%d %d %d %d %d %d",&year1,&month1,&day1,&year2,&month2,&day2);
    if(isright(year1,month1,day1)&&isright(year2,month2,day2)){
    int sum1=daysum(year1,month1,day1);
    int sum2=daysum(year2,month2,day2);
    int dif=abs(sum1-sum2);
    printf("天数差为%d\n",dif);}
    else {  printf("您输入的日期有误\n");}
    printf("按任意键返回主菜单...");
    getch();
}
//页面七的功能函数
void page7() {
    system("cls");  // 进入页面时先清屏
    printf("欢迎来到页面7！\n");
    printf("显示二十四节气\n");
    printf("请输入想要查询的年份\n");
    int iyear;
    scanf("%d",&iyear);
    termOutPut(iyear);
    printf("按任意键返回主菜单...");
    getch();
}
//页面8的功能函数
void page8() {
    system("cls");  // 进入页面时先清屏
    printf("欢迎来到页面8！\n");
    printf("显示节日\n");
    printf("1,查询公历节日\n");
    printf("2,查询阴历节日\n");
    int choice;
    scanf("%d",&choice);
    system("cls");
    if(choice==1){
        printf("欢迎来到公历节日查询\n");
        printf("请输入想要查询的公历月份\n");
        int gmonth;
        scanf("%d",&gmonth);
        if(gmonth==1) {printf("一月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "一月一日", FESTIVAL_WIDTH, "元旦");
            printf("%-*s%-*s\n", DATE_WIDTH, "一月十日", FESTIVAL_WIDTH, "中国人民警察节");
            printf("%-*s%-*s\n", DATE_WIDTH, "一月二十一日", FESTIVAL_WIDTH, "国际拥抱日");
            printf("%-*s%-*s\n", DATE_WIDTH, "一月二十七日", FESTIVAL_WIDTH, "缅怀大屠杀受难者国际纪念日");
        }
        else if(gmonth==2) {printf("二月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "二月二日", FESTIVAL_WIDTH, "世界湿地日");
            printf("%-*s%-*s\n", DATE_WIDTH, "二月四日", FESTIVAL_WIDTH, "世界抗癌日");
            printf("%-*s%-*s\n", DATE_WIDTH, "二月十日", FESTIVAL_WIDTH, "国际气象节");
            printf("%-*s%-*s\n", DATE_WIDTH, "二月十四日", FESTIVAL_WIDTH, "情人节");
            printf("%-*s%-*s\n", DATE_WIDTH, "二月二十日", FESTIVAL_WIDTH, "世界社会公正日");}
        else if(gmonth==3) {printf("三月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月一日", FESTIVAL_WIDTH, "国际民防日");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月三日", FESTIVAL_WIDTH, "世界抗癌日");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月五日", FESTIVAL_WIDTH, "学雷锋纪念日");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月八日", FESTIVAL_WIDTH, "妇女节");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月十二日", FESTIVAL_WIDTH, "植树节");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月十四日", FESTIVAL_WIDTH, "国际数学日");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月二十日", FESTIVAL_WIDTH, "国际幸福日");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月二十一日", FESTIVAL_WIDTH, "世界睡眠日");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月二十四日", FESTIVAL_WIDTH, "世界防治结核病日");
            printf("%-*s%-*s\n", DATE_WIDTH, "三月二十七日", FESTIVAL_WIDTH, "世界戏剧日");
                       }
        else if(gmonth==4){
                        printf("四月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月一日", FESTIVAL_WIDTH, "愚人节");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月二日", FESTIVAL_WIDTH, "世界自闭症日");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月七日", FESTIVAL_WIDTH, "世界卫生日");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月八日", FESTIVAL_WIDTH, "国际珍稀动物保护日");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月十五日", FESTIVAL_WIDTH, "国际安全教育日");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月十七日", FESTIVAL_WIDTH, "世界血友病日");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月二十日", FESTIVAL_WIDTH, "联合国中文日");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月二十二日", FESTIVAL_WIDTH, "世界地球日");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月二十三日", FESTIVAL_WIDTH, "世界读书日");
            printf("%-*s%-*s\n", DATE_WIDTH, "四月二十四日", FESTIVAL_WIDTH, "中国航天日");
        }
        else if(gmonth==5){
                        printf("五月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月一日", FESTIVAL_WIDTH, "国际劳动节");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月四日", FESTIVAL_WIDTH, "中国青年节");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月八日", FESTIVAL_WIDTH, "世界红十字日");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月第二个星期日", FESTIVAL_WIDTH, "母亲节");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月十二日", FESTIVAL_WIDTH, "国际护士节");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月十五日", FESTIVAL_WIDTH, "全国碘缺乏日");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月十五日", FESTIVAL_WIDTH, "国际家庭日");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月十七日", FESTIVAL_WIDTH, "世界电信日");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月三十日", FESTIVAL_WIDTH, "全国科技工作者日");
            printf("%-*s%-*s\n", DATE_WIDTH, "五月三十一日", FESTIVAL_WIDTH, "世界无烟日");
        }
        else if(gmonth==6){
                        printf("六月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "六月一日", FESTIVAL_WIDTH, "国际儿童节");
            printf("%-*s%-*s\n", DATE_WIDTH, "六月五日", FESTIVAL_WIDTH, "世界环境日");
            printf("%-*s%-*s\n", DATE_WIDTH, "六月六日", FESTIVAL_WIDTH, "全国爱眼日");
            printf("%-*s%-*s\n", DATE_WIDTH, "六月七日", FESTIVAL_WIDTH, "世界食品安全日");
            printf("%-*s%-*s\n", DATE_WIDTH, "六月第三个星期日", FESTIVAL_WIDTH, "父亲节");
            printf("%-*s%-*s\n", DATE_WIDTH, "六月二十三日", FESTIVAL_WIDTH, "国际奥林匹克日");
            printf("%-*s%-*s\n", DATE_WIDTH, "六月二十五日", FESTIVAL_WIDTH, "全国土地日");
            printf("%-*s%-*s\n", DATE_WIDTH, "六月二十六日", FESTIVAL_WIDTH, "国际禁毒日");
        }
        else if(gmonth==7){
                       printf("七月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "七月一日", FESTIVAL_WIDTH, "建党节");
            printf("%-*s%-*s\n", DATE_WIDTH, "七月十一日", FESTIVAL_WIDTH, "世界人口日");
            printf("%-*s%-*s\n", DATE_WIDTH, "七月十一日", FESTIVAL_WIDTH, "中国航海日");
            printf("%-*s%-*s\n", DATE_WIDTH, "七月三十日", FESTIVAL_WIDTH, "国际友谊日");
        }
        else if(gmonth==8){
                        printf("八月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "八月一日", FESTIVAL_WIDTH, "建军节");
            printf("%-*s%-*s\n", DATE_WIDTH, "八月八日", FESTIVAL_WIDTH, "全民健身日");
            printf("%-*s%-*s\n", DATE_WIDTH, "八月十二日", FESTIVAL_WIDTH, "国际青年节");
            printf("%-*s%-*s\n", DATE_WIDTH, "八月十三日", FESTIVAL_WIDTH, "国际左撇子日");
            printf("%-*s%-*s\n", DATE_WIDTH, "八月十五日", FESTIVAL_WIDTH, "全国生态日");
            printf("%-*s%-*s\n", DATE_WIDTH, "八月十九日", FESTIVAL_WIDTH, "中国医师节");
            printf("%-*s%-*s\n", DATE_WIDTH, "八月二十五日", FESTIVAL_WIDTH, "全国残疾预防日");
            printf("%-*s%-*s\n", DATE_WIDTH, "八月二十九日", FESTIVAL_WIDTH, "全国测绘法宣传日");
        }
        else if(gmonth==9){
                        printf("九月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "九月三日", FESTIVAL_WIDTH, "中国人民抗日战争胜利纪念日");
            printf("%-*s%-*s\n", DATE_WIDTH, "九月十日", FESTIVAL_WIDTH, "教师节");
            printf("%-*s%-*s\n", DATE_WIDTH, "九月第三个星期六", FESTIVAL_WIDTH, "全国国防教育日");
            printf("%-*s%-*s\n", DATE_WIDTH, "九月二十日", FESTIVAL_WIDTH, "公民道德宣传日");
            printf("%-*s%-*s\n", DATE_WIDTH, "九月二十一日", FESTIVAL_WIDTH, "国际和平日");
            printf("%-*s%-*s\n", DATE_WIDTH, "九月的第四个星期日", FESTIVAL_WIDTH, "国际聋人节");
            printf("%-*s%-*s\n", DATE_WIDTH, "九月二十七日", FESTIVAL_WIDTH, "世界旅游日");
            printf("%-*s%-*s\n", DATE_WIDTH, "九月三十日", FESTIVAL_WIDTH, "烈士纪念日");
        }
        else if(gmonth==10){
                       printf("十月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月一日", FESTIVAL_WIDTH, "国庆节");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月四日", FESTIVAL_WIDTH, "世界动物日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月五日", FESTIVAL_WIDTH, "世界教师日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月九日", FESTIVAL_WIDTH, "世界邮政日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月十日", FESTIVAL_WIDTH, "世界精神卫生日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月十五日", FESTIVAL_WIDTH, "国际盲人节");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月十六日", FESTIVAL_WIDTH, "世界粮食节");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月十七日", FESTIVAL_WIDTH, "世界消除贫困日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十月二十四日", FESTIVAL_WIDTH, "程序员节");
        }
        else if(gmonth==11){ printf("十一月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "十一月一日", FESTIVAL_WIDTH, "万圣节");
            printf("%-*s%-*s\n", DATE_WIDTH, "十一月八日", FESTIVAL_WIDTH, "中国记者日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十一月九日", FESTIVAL_WIDTH, "消防宣传日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十一月十七日", FESTIVAL_WIDTH, "国际大学生节");
        }
        else if(gmonth==12){
                        printf("十二月公历节日\n");
            printf("%-*s%-*s\n", DATE_WIDTH, "十二月一日", FESTIVAL_WIDTH, "世界艾滋病日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十二月二日", FESTIVAL_WIDTH, "全国交通安全日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十二月三日", FESTIVAL_WIDTH, "世界残疾人日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十二月四日", FESTIVAL_WIDTH, "国家宪法日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十二月十三日", FESTIVAL_WIDTH, "国家公祭日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十二月二十一日", FESTIVAL_WIDTH, "国际篮球日");
            printf("%-*s%-*s\n", DATE_WIDTH, "十二月二十四日", FESTIVAL_WIDTH, "平安夜");
            printf("%-*s%-*s\n", DATE_WIDTH, "十二月二十五日", FESTIVAL_WIDTH, "圣诞节");
        }
    }
    else if(choice==2){
            printf("欢迎来到农历节日查询\n");
        printf("%-*s%-*s\n", DATE_WIDTH, "正月初一", FESTIVAL_WIDTH, "春节");
        printf("%-*s%-*s\n", DATE_WIDTH, "正月十五", FESTIVAL_WIDTH, "元宵节");
        printf("%-*s%-*s\n", DATE_WIDTH, "二月初二", FESTIVAL_WIDTH, "社日节");
        printf("%-*s%-*s\n", DATE_WIDTH, "三月初三", FESTIVAL_WIDTH, "上巳节");
        printf("%-*s%-*s\n", DATE_WIDTH, "公历四月五日", FESTIVAL_WIDTH, "清明节");
        printf("%-*s%-*s\n", DATE_WIDTH, "五月五日", FESTIVAL_WIDTH, "端午节");
        printf("%-*s%-*s\n", DATE_WIDTH, "七月七日", FESTIVAL_WIDTH, "七夕节");
        printf("%-*s%-*s\n", DATE_WIDTH, "七月十五日", FESTIVAL_WIDTH, "中元节");
        printf("%-*s%-*s\n", DATE_WIDTH, "八月十五日", FESTIVAL_WIDTH, "中秋节");
        printf("%-*s%-*s\n", DATE_WIDTH, "九月初九", FESTIVAL_WIDTH, "重阳节");
        printf("%-*s%-*s\n", DATE_WIDTH, "十月十五", FESTIVAL_WIDTH, "下元节");
        printf("%-*s%-*s\n", DATE_WIDTH, "腊月廿九或三十", FESTIVAL_WIDTH, "除夕");

    }
    printf("按任意键返回主菜单...");
    getch();
}
// 主菜单函数
void mainMenu(SYSTEMTIME curtime,int csum,int cyear,int cmonth,int cday) {
    int choice;
    system("cls");  // 显示菜单前先清屏
    printf( "\t\t\t万年历\n");
    printf("\t\tTime : %hu年%hu月%hu日 %2hu:%2hu \n",curtime.wYear,curtime.wMonth,curtime.wDay,curtime.wHour,curtime.wMinute);
    printf("1,查询农历\n");
    printf("2,查询公历\n");
    printf("3,显示月历\n");
    printf("4,查询某天距今天的天数\n");
    printf("5,查询距今天相应天数的日期\n");
    printf("6,查询任意两天之间的天数差\n");
    printf("7,显示二十四节气\n");
    printf("8,显示节日\n");
    printf("0，退出万年历程序\n");
    printf("请输入你的选择：\n");

    // 安全读取整数输入
    if (scanf("%d", &choice) != 1) {
        // 处理非整数输入
        while (getchar() != '\n'); // 清空输入缓冲区
        choice = -1; // 设置为无效值
    } else {
        // 清除scanf后残留的换行符
        while (getchar() != '\n');
    }

    switch (choice) {
    case 1:
        page1();
        mainMenu(curtime,csum,cyear,cmonth,cday);
        break;
    case 2:
        page2();
        mainMenu(curtime,csum,cyear,cmonth,cday);

        break;
    case 3:
        page3();
        mainMenu(curtime,csum,cyear,cmonth,cday);
        break;
    case 4:
        page4(csum,cyear,cmonth,cday);
        mainMenu(curtime,csum,cyear,cmonth,cday);
        break;
    case 5:
        page5(csum,cyear,cmonth,cday);
        mainMenu(curtime,csum,cyear,cmonth,cday);
        break;
    case 6:
        page6();
        mainMenu(curtime,csum,cyear,cmonth,cday);
        break;
    case 7:
        page7();
        mainMenu(curtime,csum,cyear,cmonth,cday);
        break;
    case 8:
        page8();
        mainMenu(curtime,csum,cyear,cmonth,cday);
        break;
    case 0:
        printf("程序退出\n");
        break;
    default:
        printf("无效的选择，请按任意键继续...");
        getch();
        mainMenu(curtime,csum,cyear,cmonth,cday);
        break;
    }
}

int main() {
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(hConsole,
        FOREGROUND_RED |
        BACKGROUND_RED |BACKGROUND_BLUE |BACKGROUND_GREEN
    );
    SYSTEMTIME curtime;
    GetLocalTime(&curtime);
    int cyear;
    cyear=curtime.wYear;
    int cmonth;
    cmonth=curtime.wMonth;
    int cday;
    cday=curtime.wDay;
    int csum=daysum(cyear,cmonth,cday);
    mainMenu(curtime,csum,cyear,cmonth,cday);
    return 0;
}
